﻿using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Storage;
using Microsoft.Xna.Framework.Content;

namespace MageDefender.Scenes
{
    public class IntroScene : Microsoft.Xna.Framework.DrawableGameComponent
    {
        bool changeScene = false;
        float changeSceneTimer = 0;

        public float ChangeSceneTimer
        {
            get { return changeSceneTimer; }
            set { changeSceneTimer = value; }
        }

        public bool ChangeScene
        {
            get { return changeScene; }
            set { changeScene = value; }
        }

        Texture2D texTest;
        SpriteBatch spriteBatch;

        public IntroScene(Game game)
            : base(game)
        {
            // TODO: Construct any child components here
        }

        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        public override void Initialize()
        {
            // TODO: Add your initialization code here
            texTest = this.Game.Content.Load<Texture2D>("Textures\\loading");

            base.Initialize();
        }

        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            base.LoadContent();
        }


        /// <summary>
        /// Allows the game component to update itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            // TODO: Add your update code here
            changeSceneTimer += gameTime.ElapsedGameTime.Milliseconds;
            if (changeSceneTimer > 1000)
            {
                changeScene = true;
                changeSceneTimer = 0;
            }
            base.Update(gameTime);
        }

        public override void Draw(GameTime gameTime)
        {
            spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Deferred, SaveStateMode.SaveState);
            spriteBatch.Draw(texTest, new Rectangle(0, 0, Game.GraphicsDevice.PresentationParameters.BackBufferWidth, Game.GraphicsDevice.PresentationParameters.BackBufferHeight), Color.White);
            spriteBatch.End();

            base.Draw(gameTime);
        }
    }
}
